package cn.xs.goods.service.impl;


import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.xs.core.service.impl.BaseServiceImpl;
import cn.xs.goods.dao.CategoryDao;
import cn.xs.goods.entity.Category;
import cn.xs.goods.service.CategoryService;

@Service("categoryService")
public class CategoryServiceImpl extends BaseServiceImpl<Category> implements
		CategoryService {

	private CategoryDao categoryDao;
	@Resource
	public void setCategoryDao(CategoryDao categoryDao) {
		super.setBaseDao(categoryDao);
		this.categoryDao = categoryDao;
	}
	
	
	public List<Category> findParentsCategory() {
		List<Category> results = categoryDao.findParentsCategory();
		//填充子分类
		for(Category c:results){
			List<Category> childrens = categoryDao.findCategorysByPid(c.getId());
			c.setChildren(childrens);
		}
		return results;
	}


	public List<Category> findCategorysByPid(String pid) {
		return categoryDao.findCategorysByPid(pid);
	}
}
